import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: YKH
 * Date: 2022-04-26
 * Time: 9:29
 */
public class Test01 {
    public List<List<Integer>> generate(int numRows) {
       List<List <Integer>> ret = new ArrayList<>();
        List<Integer> one = new ArrayList<>();
        one.add(1);
        ret.add(one);
        for (int i = 1; i < numRows; i++) {
            List<Integer> curRows = new ArrayList<>();
            List<Integer> prev = new ArrayList<>();
            prev = ret.get(i-1);
            curRows.add(1);
            for (int j = 1; j < i; j++) {
                curRows.add( prev.get(j) + prev.get(j-1));
            }
            curRows.add(1);
            ret.add(curRows);
        }
        return ret;
    }
}
